package com.example.android.BluetoothChat.util.provider.player.impl;

import java.util.ArrayList;
import java.util.List;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;

import com.example.android.BluetoothChat.bean.Game;
import com.example.android.BluetoothChat.bean.GameRequestResponse;
import com.example.android.BluetoothChat.bean.Player;
import com.example.android.BluetoothChat.listener.NewPlayerFoundListener;
import com.example.android.BluetoothChat.util.provider.IPlayerProvider;

/**
 * Use all available IDiscoveryService implementations to get players and games nearby
 * @author theo
 *
 */
public class GlobalPlayerProviderImpl extends APlayerProviderImpl {
	// discover services to use
	private List<IPlayerProvider> __playerProviderList = new ArrayList<IPlayerProvider>();
	private BluetoothPlayerProviderImpl _bluetoothPlayerProvider = null;

	public 	GlobalPlayerProviderImpl(){		

		_bluetoothPlayerProvider = new BluetoothPlayerProviderImpl();
		__playerProviderList.add(_bluetoothPlayerProvider);			
		__playerProviderList.add(new MockPlayerProviderImpl());
	}

	@Override
	public final void addNewPlayerFoundListener(NewPlayerFoundListener parListener) {
		for(IPlayerProvider _playerProvider : __playerProviderList){
			_playerProvider.addNewPlayerFoundListener(parListener);
		}
	}



	@Override
	public void findPlayersNearby(Context parContext) {
		
		for(IPlayerProvider locDiscoveryService : __playerProviderList){
			locDiscoveryService.findPlayersNearby(parContext);
		}
	}

	@Override
	public void askPlayerToPlay(Player parPlayer, Game parGame) {
		// TODO Auto-generated method stub

	}

	@Override
	public void handleResponseForPlaying(
			GameRequestResponse parGameRequestResponse) {
		// TODO Auto-generated method stub

	}


}
